package com.zengde.ai_sandbox.controller;

import com.zengde.ai_sandbox.dto.ChatMessage;
import com.zengde.ai_sandbox.service.ChatSessionManager;
import org.springframework.web.bind.annotation.*;
import reactor.core.publisher.Flux;

@RestController
@RequestMapping("/api/chat")
public class ChatController {
    
    private final ChatSessionManager chatManager;
    
    public ChatController(ChatSessionManager chatManager) {
        this.chatManager = chatManager;
    }
    
    @PostMapping("/initiate")
    public boolean initiateChat(@RequestParam String customerId, @RequestBody String message) {
        return chatManager.initiateChat(customerId, message);
    }
    
    @PostMapping("/send")
    public String sendMessage(@RequestParam String customerId, @RequestBody String message) {
        return chatManager.sendMessage(customerId, message);
    }
    
    @PostMapping("/stream")
    public Flux<String> sendStreamMessage(@RequestParam String customerId, @RequestBody String message) {
        return chatManager.sendStreamMessage(customerId, message);
    }
    
    @DeleteMapping("/end")
    public void endChat(@RequestParam String customerId) {
        chatManager.endChat(customerId);
    }
}
